def info_print():
    print(f'----功能界面----')
    print('1、添加学员')
    print('2、删除学员')
    print('3、修改学员')
    print('4、查询学员')
    print('5、显示所有学员')
    print('6、退出系统')
    print("-" * 10)


info_list = []  # 存储 全局变量


def add_info():
    id = input('请输入学号:')
    name = input('请输入姓名:')
    global info_list
    for i in info_list:
        if i['name'] == name:
            print('已有重名学员')
            return
    info_dic = {}
    info_dic['id'] = id
    info_dic['name'] = name
    info_list.append(info_dic)
    print(info_list)


def del_info():
    name = input('请输入要删除的学员姓名：')
    global info_list
    for i in info_list:
        if name == i['name']:
            info_list.remove(i)
            print('删除成功')
            break
    else:
        print('该学员不存在')
    print(info_list)


def modify_info():
    name = input('请输入要修改的学员姓名：')
    global info_list
    for i in info_list:
        if name == i['name']:
            id = input('请输入要修改的学号：')
            i['id'] = id
            print('修改成功')
            break
    else:
        print('该学员不存在')
    print(info_list)


def search_info():
    name = input('请输入要查询的学员姓名：')
    global info_list
    for i in info_list:
        if name == i['name']:
            print(i)
            break
    else:
        print('该学员不存在')


def print_all():
    global info_list
    print('学号\t姓名')
    for i in info_list:
        print(f"{i['id']}    {i['name']}")


while True:
    info_print()
    user_num = int(input('请输入功能序号：'))
    if user_num == 1:
        add_info()
    elif user_num == 2:
        del_info()
    elif user_num == 3:
        modify_info()
    elif user_num == 4:
        search_info()
    elif user_num == 5:
        print_all()
    elif user_num == 6:
        print('退出系统')
        break
    else:
        print('输入有误')
    print('\n')
